/**
 * Create by richliu1023
 * @date 16/5/19
 * @email richliu1023@gmail.com
 * @github https://github.com/RichLiu1023
 * @description a simple explanation
 */
class UIController {
	private static _uiLayer:egret.DisplayObjectContainer;
	private static _topLayer:egret.DisplayObjectContainer;
	private static _bottomLayer:egret.DisplayObjectContainer;
	private static _tipsLayer:UITipsLayer;
	private static _loadingLayer:egret.DisplayObjectContainer;
	private static _noticeLayer:egret.DisplayObjectContainer;
	private static _main:egret.DisplayObjectContainer;

	public constructor() {
	}

	public static setup( main:egret.DisplayObjectContainer ):void {
		if ( main ) {
			this._main = main;
			this._topLayer = new egret.DisplayObjectContainer();
			this._bottomLayer = new egret.DisplayObjectContainer();
			this._uiLayer = new egret.DisplayObjectContainer();
			this._tipsLayer = new UITipsLayer();
			this._noticeLayer = new egret.DisplayObjectContainer();
			this._loadingLayer = new UILoading();
			main.addChild( this._bottomLayer );
			main.addChild( this._uiLayer );
			main.addChild( this._noticeLayer );
			main.addChild( this._tipsLayer );
			main.addChild( this._topLayer );
			main.addChild( this._loadingLayer );
			this._main.stage.addEventListener( egret.TouchEvent.TOUCH_TAP,
											   this.onClick,
											   this,
											   false,
											   Number.POSITIVE_INFINITY );
		}
	}

	private static onClick( touch:egret.TouchEvent ):void {
		var typeName = egret.getQualifiedClassName( touch.target );
		switch ( typeName ) {
			case 'eui.Button':
			case 'eui.ToggleSwitch':
			{
				//SoundManager.playButton();
				break;
			}
		}
		( this._tipsLayer.isJump ) ? this._tipsLayer.isJump = false : this._tipsLayer.removeChildren();
	}

	public static get uiLayer():egret.DisplayObjectContainer {
		return this._uiLayer;
	}

	public static get topLayer():egret.DisplayObjectContainer {
		return this._topLayer;
	}

	public static get tipsLayer():UITipsLayer {
		return this._tipsLayer;
	}

	public static get noticeLayer():egret.DisplayObjectContainer {
		return this._noticeLayer;
	}

	public static get bottomLayer():egret.DisplayObjectContainer {
		return this._bottomLayer;
	}

	public static disableLoading( value:boolean ):void {
		this._loadingLayer.visible = value;
	}
}